#include <stdio.h>

#include "core/hs_log.h"
#include "core/hs_window.h"
#include "core/hs_time.h"

void keyboard(p_event_key event);
void mouse(p_event_mouse event);

Wnd Window(1024, 768, false, "Test", &mouse, &keyboard);

void keyboard(p_event_key event) {
  printf("Key %d\n", event -> Id);
  if (event->Id == 27 && event->State == KS_DOWN && event->Property == KP_VIRTUALKEY) {
    Window.SetRunning(false);
  };  
  if (event->Id == 13 && event->State == KS_DOWN && event->Property == KP_VIRTUALKEY && 
      event -> Alt) {
    Window.SetMode(1024, 768, !Window.GetFullScreen());
  }; 
}

void mouse(p_event_mouse event) {
  if (event -> State == MS_UP) {
    printf("Mouse X: %d Y: %d\n", event -> X, event -> Y);
  }
  if (event -> State == MS_WHEEL) {
    printf("Mouse Wheel %d\n", event -> Wheel);
  }  
}

int main(int /*argc*/, char* /*argv*/[]) {
  time_init();
  // printf("hs_core version: %d\n", hs.version);
  log_set_file("log.txt", LF_TEXT);
  log(" this is normal message");
  log("!this is error message");
  log("-this is warrning message");
  log("?this is assertion error");
  // log_set_file("log.html", LF_HTML);
  // log(" this is normal message");
  // log("!this is error message");
  // log("-this is warrning message");
  // log("?this is assertion error");

  int start = time();
  log(" Waiting for 100 ms from %d", start);
  while (time() - start < 100) {}
  log(" Now: %d", time());

  Window.SetCaption("HumanSoul version 0.1");
  Window.Run();

  return 0;
}
